import axios from 'axios';

// const host = 'http://101.37.69.11';
const host = '/';
// const host =
//     'https://midjourney-lab-backend.fcv3.1295227162629279.cn-hangzhou.fc.devsapp.net';

const api = axios.create({
    baseURL: host,
    timeout: 10000,
    headers: {
        'Content-Type': 'application/json',
    },
});

// 请求拦截器
api.interceptors.request.use(
    (config) => {
        // console.log('Request:', config);
        return config;
    },
    (error) => {
        console.error('Request error:', error);
        return Promise.reject(error);
    }
);

// 响应拦截器
api.interceptors.response.use(
    (response) => {
        // console.log('Response:', response);
        return response;
    },
    (error) => {
        console.error('Response error:', error);
        return Promise.reject(error);
    }
);

export default api;

export { host };
